import basic from './basic.js';
var actmodel = new basic();
actmodel.offset = function (that, reset, para, xcsorts) {
  if (!xcsorts) {
    xcsorts = [["id", "desc"], ["modifytime", "desc"]];
  }

  var acturlpara = {};
  acturlpara["url"] = "entry/wxapp/shop_clubaddr"
  if (para) {
    para["op"] = "offset"
  }
  else {
    this.wherepara["op"] = "offset"
  }
  return actmodel.pagelist(acturlpara, that, reset, para, xcsorts);
}

/**
 * 
 * @param {*} lat 
 * @param {*} lng 
 * @param {*} autarky 
 */
actmodel.nearby=function(lat,lng,autarky,pickmethod){
  var app = getApp();
  var data = { "op": "nearby", lat,lng,autarky,pickmethod }
  return new Promise((resolve, reject) => {
    app.util.request({
      'url': 'entry/wxapp/shop_clubaddr',
      'data': data,
      'method': "get",
      showLoading: false,
      success: function (res) {
        if (res.data.errno == 0) {
          resolve(res.data.data);
        }
        reject(res.data.message);
      },
      fail: function (res) {
        reject(((res.data && res.data.message) ? res.data.message : res.errMsg));
      },
      complete: function () {
      }
    });
  });
}


actmodel.getmodel=function(id){
  var app = getApp();
  var data = { "op": "getmodel", id }
  return new Promise((resolve, reject) => {
    app.util.request({
      'url': 'entry/wxapp/shop_clubaddr',
      'data': data,
      'method': "get",
      showLoading: false,
      success: function (res) {
        if (res.data.errno == 0) {
          resolve(res.data.data);
        }
        reject(res.data.message);
      },
      fail: function (res) {
        reject(((res.data && res.data.message) ? res.data.message : res.errMsg));
      },
      complete: function () {
      }
    });
  });
}

module.exports = actmodel;
